let xxx = {
    name: 'xxx',
    data() {
        return {
            // 菜单列表
            menuList: [
                {
                    icon: 'public/static/images/menu-icon/setup.png',
                    name: '商城管理',
                    isActive: false,
                    children: [
                        {
                            icon: 'public/static/images/menu-icon/setup.png',
                            name: '商品分类',
                            path: '/shop-goods-category',
                            isActive: false
                        },
                        {
                            icon: 'public/static/images/menu-icon/setup.png',
                            name: '商品列表',
                            path: '/shop-goods-lists',
                            isActive: false
                        },
                        {
                            icon: 'public/static/images/menu-icon/setup.png',
                            name: '商城订单',
                            path: '/shop-goods-order',
                            isActive: false
                        }
                    ]
                },
                {
                    icon: 'public/static/images/menu-icon/setup.png',
                    name: '租赁管理',
                    isActive: false,
                    children: [
                        {
                            icon: 'public/static/images/menu-icon/setup.png',
                            name: '租赁分类',
                            path: '/lease-goods-category',
                            isActive: false
                        },
                        {
                            icon: 'public/static/images/menu-icon/setup.png',
                            name: '商品列表',
                            path: '/lease-goods-lists',
                            isActive: false
                        }
                    ]
                },
                {
                    icon: 'public/static/images/menu-icon/setup.png',
                    name: '资讯管理',
                    isActive: false,
                    children: [
                        {
                            icon: 'public/static/images/menu-icon/setup.png',
                            name: '资讯分类',
                            path: '/news-category',
                            isActive: false
                        },
                        {
                            icon: 'public/static/images/menu-icon/setup.png',
                            name: '资讯列表',
                            path: '/news-lists',
                            isActive: false
                        }
                    ]
                },
                {
                    icon: 'public/static/images/menu-icon/setup.png',
                    name: '用户管理',
                    isActive: false,
                    children: [
                        {
                            icon: 'public/static/images/menu-icon/setup.png',
                            name: '用户列表',
                            path: '/user-lists',
                            isActive: false
                        },
                        {
                            icon: 'public/static/images/menu-icon/setup.png',
                            name: '会员等级',
                            path: '/user-level',
                            isActive: false
                        }
                    ]
                },
                {
                    icon: 'public/static/images/menu-icon/setup.png',
                    name: '管理员管理',
                    isActive: false,
                    children: [
                        {
                            icon: 'public/static/images/menu-icon/setup.png',
                            name: '管理员列表',
                            path: '/admin-lists',
                            isActive: false
                        }
                    ]
                }
            ],
            // 最后一个打开的主菜单索引
            lastOpenMainMenuIndex: null,
            // 最后一个打开的次级菜单索引
            lastOpenSubMenuIndex: null
        };
    },
    methods: {
        // 切换主菜单
        switchMainMenu(item, index) {
            if (this.lastOpenMainMenuIndex !== null) {
                this.menuList[this.lastOpenMainMenuIndex].isActive = false;
            }
            this.lastOpenMainMenuIndex = index;
            item.isActive = true;
        },
        // 切换次级菜单
        switchSubMenu(mainItem, mainIndex, subItem, subIndex) {
            if (this.lastOpenMainMenuIndex !== null && this.lastOpenSubMenuIndex !== null) {
                this.menuList[this.lastOpenMainMenuIndex].children[this.lastOpenSubMenuIndex].isActive = false;
            }
            this.lastOpenSubMenuIndex = subIndex;
            subItem.isActive = true;
            this.$router.push(subItem.path);
        }
    },
    template: document.getElementById('xxx').innerHTML
};
Vue.component('xxx', xxx);
